//
// Created by wkm on 2023-12-05.
//

#include "usr.h"

void usr::prc_usr() {
    sc_uint<WIDTH> q_temp;
    sc_uint<SEL_WIDTH> sel_temp;

    if (!clr) {
        q = 0;
    } else {
        q_temp = q.read();   //读取输出端口值
        sel_temp = select.read();

        switch (sel_temp) {
            case HOLD :
                break;  // 保持值
            case SHIFT_LEFT:
                q = (q_temp.range(WIDTH - 2, 0), rin.read());
                break;
            case SHIFT_RIGHT:
                q = (lin.read(), q_temp.range(WIDTH - 1, 1));
                break;
            case LOAD:
                q = par_in;
                break;
        }
    }
}